from tortoise.models import Model
from tortoise import fields
from datetime import datetime


class Customer(Model):
    """
    客户信息模型
    """
    cusid = fields.IntField(pk=True, description="客户ID")
    cusname = fields.CharField(max_length=64, null=True, description="客户名称")
    ename = fields.CharField(max_length=32, null=True, description="助记码")
    code = fields.CharField(max_length=32, null=True, description="客户编码")
    connector = fields.CharField(max_length=32, null=True, description="老板名称")
    telephone = fields.CharField(max_length=32, null=True, description="电话")
    address = fields.CharField(max_length=255, null=True, description="地址")
    level = fields.CharField(max_length=20, null=True, description="合作深度")
    region = fields.CharField(max_length=20, null=True, description="片区")
    channel = fields.CharField(max_length=20, null=True, description="渠道")
    isin = fields.CharField(max_length=10, null=True, description="是否入场")
    statu = fields.CharField(max_length=20, null=True, description="状态")
    owner = fields.CharField(max_length=20, null=True, description="所属员工")
    paytype = fields.CharField(max_length=20, null=True, description="付款方式")
    create_by = fields.CharField(max_length=64, null=True, description="创建者")
    create_time = fields.DatetimeField(auto_now_add=True, description="创建时间")
    update_by = fields.CharField(max_length=64, null=True, description="更新者")
    update_time = fields.DatetimeField(auto_now=True, description="更新时间")
    remark = fields.CharField(max_length=500, null=True, description="备注")
    del_flag = fields.CharField(max_length=1, default="0", description="删除标志(0代表存在 2代表删除)")

    class Meta:
        table = "wms_customer"
        table_description = "客户信息表"

    def __str__(self):
        return f"Customer(cusid={self.cusid}, cusname={self.cusname})"